package com.ruoyi.ruoyiMenu.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.ruoyiMenu.domain.TestTable;
import com.ruoyi.ruoyiMenu.service.ITestTableService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 若依代码生成测试Controller
 * 
 * @author 凡诚
 * @date 2022-11-06
 */
@RestController
@RequestMapping("/ruoyiMenu/testTable")
public class TestTableController extends BaseController
{
    @Autowired
    private ITestTableService testTableService;

    /**
     * 查询若依代码生成测试列表
     */
    @PreAuthorize("@ss.hasPermi('ruoyiMenu:testTable:list')")
    @GetMapping("/list")
    public TableDataInfo list(TestTable testTable)
    {
        startPage();
        List<TestTable> list = testTableService.selectTestTableList(testTable);
        return getDataTable(list);
    }

    /**
     * 导出若依代码生成测试列表
     */
    @PreAuthorize("@ss.hasPermi('ruoyiMenu:testTable:export')")
    @Log(title = "若依代码生成测试", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TestTable testTable)
    {
        List<TestTable> list = testTableService.selectTestTableList(testTable);
        ExcelUtil<TestTable> util = new ExcelUtil<TestTable>(TestTable.class);
        util.exportExcel(response, list, "若依代码生成测试数据");
    }

    /**
     * 获取若依代码生成测试详细信息
     */
    @PreAuthorize("@ss.hasPermi('ruoyiMenu:testTable:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(testTableService.selectTestTableById(id));
    }

    /**
     * 新增若依代码生成测试
     */
    @PreAuthorize("@ss.hasPermi('ruoyiMenu:testTable:add')")
    @Log(title = "若依代码生成测试", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TestTable testTable)
    {
        return toAjax(testTableService.insertTestTable(testTable));
    }

    /**
     * 修改若依代码生成测试
     */
    @PreAuthorize("@ss.hasPermi('ruoyiMenu:testTable:edit')")
    @Log(title = "若依代码生成测试", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TestTable testTable)
    {
        return toAjax(testTableService.updateTestTable(testTable));
    }

    /**
     * 删除若依代码生成测试
     */
    @PreAuthorize("@ss.hasPermi('ruoyiMenu:testTable:remove')")
    @Log(title = "若依代码生成测试", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(testTableService.deleteTestTableByIds(ids));
    }
}
